Set Field Values

Set Field Values for Logged-In User

Description
Set the value of a field based on the identity of the currently logged-in user.
Variables
Record Control Class
Select the record control where this customization will be inserted
Field Control
Select the field whose value needs to be set.
Applies to
RecordControl class
Code
 
/// 
/// Override the Databind() method, call the base DataBind() method and 
/// set the value of a field based on the identity of the currently
/// logged-in user.
/// 
public override void DataBind()
{

    // Call base.DataBind()
    base.DataBind();

    // If the user is logged-in set the text of the control
    // equal to the loginId
    if (!(this.Page.CurrentSecurity.GetUserStatus() == "")) 
    {
        this.${Field Control}.Text = "Created by: " + this.Page.CurrentSecurity.GetUserStatus();
    }
    else
    {
        // Since the user is not logged in set ${Field Control} text to any value.
        this.${Field Control}.Text = "Not Signed In";        
    }
}
     

Terms of Service Privacy Statement